使用Hardhat (Using Hardhat)
Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software. It helps developers manage and automate the recurring tasks that are inherent to the process of building smart contracts and dApps, as well as easily introduce more functionality around this workflow. This means compiling, running, and testing smart contracts at the very core.
Hardhat 是一个用于编译、部署、测试和调试以太坊软件的开发环境。它可以帮助开发人员管理和自动化在构建智能合约和 dApp 过程中固化的重复任务,并围绕此工作流程轻松引入更多功能。这意味着在核心上编译、运行和测试智能合约。
We will not describe the details of using the Hardhat framework here. You can find all necessary documentation by following this link: https://hardhat.org/getting-started/#overview.
我们不会在这里描述使用 Hardhat 框架的细节。您可以通过以下链接找到所有必要的文档:https://hardhat.org/getting-started/#overview。
As Neon is an Ethereum-compatible virtual machine and RPC, you can easily migrate existing Hardhat projects to it. The only thing required is the correct hardhat.config.js
file. You can refer to the code below as an example of config-file content:
由于 Neon 是与 Ethereum 兼容的虚拟机和 RPC,您可以轻松地将现有的 Hardhat 项目迁移到Neon。唯一需要的是正确的 hardhat.config.js
文件。您可以参考以下代码作为配置文件内容的示例:
require("@nomiclabs/hardhat-waffle");
const proxy_url = 'https://proxy.devnet.neonlabs.org/solana';
const network_id = 245022926;
const deployerPrivateKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxx'; // place your private key here (note that wallet must have non-zero balance of NEONs to pay fees)
module.exports = {
solidity: "0.8.4",
defaultNetwork: 'neonlabs',
networks: {
neonlabs: {
url: proxy_url,
accounts: [deployerPrivateKey],
network_id: network_id,
chainId: network_id,
gas: 3000000,
gasPrice: 1000000000,
blockGasLimit: 10000000,
allowUnlimitedContractSize: false,
timeout: 1000000,
isFork: true
}
}
};
Hardhat项目示例 (Example Hardhat Project)
You can obtain an example Hardhat project from here:
您可以从此处获取示例 Hardhat 项目:
https://github.com/neonlabsorg/examples/tree/main/simple-erc20-hardhat.